﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChinaLeg.Web.Lib
{
    public sealed class ConfigSingleton
    {
        static volatile ConfigSingleton instance = null;
        private readonly static Object readObj = new Object();

        #region private field
        private string _siteName;//网站名称
        private string _uploadfileroot; //上传文件根目录
        private string _url;
        private string _ip;
        #endregion

        #region Method
        /// <summary>
        /// 构造函数
        /// </summary>
        ConfigSingleton()
        {
            _siteName = "中国腿部整形网";
            _uploadfileroot = "/upfiles";
            _url = System.Configuration.ConfigurationManager.AppSettings["Url"];
            _ip = System.Configuration.ConfigurationManager.AppSettings["AllowIp"];
        }

        /// <summary>
        /// Singleton patten
        /// </summary>
        public static ConfigSingleton Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (readObj)
                    {
                        if (instance == null)
                        {
                            instance = new ConfigSingleton();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            instance = null;
        }
        #endregion

        #region Property
        /// <summary>
        /// 网站名称
        /// </summary>
        public string SiteName
        {
            get { return _siteName; }
        }

        public string Url
        {
            get { return _url; }
        }

        public string UploadFileRoot
        {
            get { return _uploadfileroot; }
        }
        public string IP
        {
            get { return _ip; }
        }
        #endregion
    }
}